﻿using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class TJ_GRSRHZModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                InitPage();

            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();

        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);
            string station = (this.Station.Text).ToString();
            string type = (this.Type.Value);
            string role = "";
            switch (type)
            {
                case "Driver":
                    role = "司机";
                    break;
                case "DoctorAndNurse":
                    role = "医生";
                    break;
                case "StretcherBearersI":
                    role = "担架工";
                    break;
                default:
                    break;
            }
            string name = (this.Name.Text).ToString(); //姓名
     
            string start1 = beginTime.ToString();
            string end1 = endTime.ToString();

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_GRSRHZ.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("startTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("endTime", end1);
            Microsoft.Reporting.WebForms.ReportParameter ty = new Microsoft.Reporting.WebForms.ReportParameter("type", type);
            Microsoft.Reporting.WebForms.ReportParameter rl = new Microsoft.Reporting.WebForms.ReportParameter("role", role);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed, ty, rl });
            TJDAL dal = new TJDAL();
            this.Page.Title = "急救中心个人收入汇总表";
            DataTable dt = dal.Get_TJ_JJZXGRSRHZ(beginTime, endTime,station, type,name);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_FLHZ", dt));

            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}